package com.chenj.springbootgrpcserver.config;

import com.chenj.springbootgrpcserver.interceptor.LogGrpcInterceptor;
import io.grpc.ServerInterceptor;
import net.devh.boot.grpc.server.interceptor.GrpcGlobalServerInterceptor;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 * 为了让LogGrpcInterceptor可以在gRPC请求到来时被执行，需要做相应的配置，如下所示，在普通的bean的配置中添加注解即可
 * </p>
 *
 * @since: 2022/8/13 17:45
 * @author: liyi
 */
@Configuration(proxyBeanMethods = false)
public class GlobalInterceptorConfiguration {
    @GrpcGlobalServerInterceptor
    ServerInterceptor logServerInterceptor() {
        return new LogGrpcInterceptor();
    }
}

